import com.sun.org.apache.xpath.internal.operations.String;
import org.junit.Test;

import java.io.*;

public class test {

    @Test
    public void test() throws IOException {

        File file = new File("E:\\GZ2148班上课资料\\JAVASE\\day1\\code");
        FileInputStream fis = new FileInputStream(file + "\\0.png");
        FileOutputStream fos = new FileOutputStream(file + "\\1.png");

        try {
            int count = 0;
            byte[] bbuf = new byte[102400];
            int hasRead = 0;
            while ((hasRead = fis.read(bbuf)) > 0) {
                 fos.write(bbuf, 0, hasRead);
                count++;
            }
            System.out.println(count);
        } catch (IOException E){
            E.printStackTrace();
        } finally {
            fos.flush();
            fis.close();
            fos.close();
        }
    }

    @Test
    public void test3() throws IOException {
        File file =new File("D:\\ad.txt");
        //创建StringWriter对象
        Writer w = new StringWriter();

        //写字符数组
        w.write(new char[] {'a','b','c'});

        //写字符串
        w.write("今天天气凉爽");

        w.write("就写前面7个字后面不写了", 0, 7);

        //刷新缓冲区
        w.flush();

        System.out.println(w);

        System.out.println("写好了...");
    }
}
